#include "define.h"

extern unsigned char PBLAZEPORT[]; // port 
volatile unsigned int start , end ; 

void delay(int n) { // 
    int i, j;
    for (i = 0; i < n; i++) {
        for (j = 0; j < 1000; j++) {
        }
    }
}

void delay_ms( int n) {
    int i = 250;
    start =   ((unsigned)PBLAZEPORT[TIM_BASEADDR+1]<<8)| PBLAZEPORT[TIM_BASEADDR] ;
    start = start + n ;
    // end = start + n ;
    for(i=0;i<10;) {
        end = ((unsigned)PBLAZEPORT[TIM_BASEADDR+1]<<8)| PBLAZEPORT[TIM_BASEADDR];
        if(end > start) {
            break  ;
        }
        // break ;
    }
}

void main() {
    unsigned int s ; 
    PBLAZEPORT[GPIO_BASEADDR] = 0 ;
    for(;;) {
        delay(500);  
        PBLAZEPORT[GPIO_BASEADDR] = PBLAZEPORT[GPIO_BASEADDR]+1; 
        // s = ((unsigned)PBLAZEPORT[TIM_BASEADDR+1]<<8)| PBLAZEPORT[TIM_BASEADDR] ;
        // PBLAZEPORT[GPIO_BASEADDR] = (s>>8)&0x01;
    }
}

